<?php
namespace Twoir\System\Model;

use Twoir\System\Support\ModelTrait;
use Twoir\System\Support\ParseTrait;

/**
 * 新闻模型（静态方法php8.0）
 *
 * 一个模型关联8张表， 正式表3张，待审核2张，存档表3张
 * 可通过方法/方法用的参数选择3张(最多)，可以进增删改查操作
 * cighsen02 365182575
 * 2022.06.15
 **/
class News
{
    use ModelTrait, ParseTrait;

	//模型名称
	const MODEL     = 'news';
	//prefix 模型前缀
	const MPREFIX   = 'ecms_';

	const TABLE     = [
		//引索表
		'index'		=> '_index',
		//线上表
		'pri' 		=> '',
		'sec' 		=> '_data_',//可建立分表 默认是1

		 //审核表
		'check_pri' => '_check',
		'check_sec' => '_check_data',
		//存档
		'doc_index' => '_doc_index',
		'doc_pri' 	=> '_doc',
		'doc_sec' 	=> '_doc_data',
	];

	//主键字段
	const PRIMARY   = 'id';

	/**
	 * 有两个相同字段 classid id
	*/
	const FIELD = [
	    'index' => [
	        'id','classid','checked','newstime','truetime','lastdotime','havehtml'

	        //自字义字段
	    ],

	    //完整内容

		'pri'   => [
		    'id','classid','isurl','titleurl','isqf','havehtml','istop','isgood','firsttitle','ismember','userid','username','eckuid','plnum','totaldown','onclick','newstime','truetime','lastdotime','titlepic','title',
		    'ttid','newspath','filename','ispic','groupid','userfen','titlefont','stb','fstb','restb','keyboard',

		    //自定义字段
		    'diggtop'
		],
		'sec'   => [
		    'id','classid','keyid','dokey','newstempid','closepl','haveaddfen','infotags',

		    //自定义字段
		    'writer','befrom','newstext'
	    ],
	];

	/**
	 * 默认值
	 */
	const MYDEFAULT = [
		//引索表
		'index' => [
		    'id'        => null,
		    'classid'   => 0,
		    'checked'   => 0,
		    'newstime'  => 0,
		    'truetime'  => 0,
		    'lastdotime'=> 0,
		    'havehtml'  => 0
		],
		//主表
		'pri'   => [
		    //系统字段
		    'id'        => null,
		    'classid'   => 0,
		    'isurl'     => 0,
		    'titleurl'  => '',
		    'isqf'      => 0,
		    'havehtml'  => 0,
		    'istop'     => 0,
		    'isgood'    => 0,
		    'firsttitle'=> 0,
		    'ismember'  => 0,
		    'userid'    => 0,
		    'username'  => '',
		    'eckuid'    => 0,
		    'plnum'     => 0,
		    'totaldown' => 0,
		    'onclick'   => 0,
		    'newstime'  => 0,
		    'truetime'  => 0,
		    'lastdotime'=> 0,
		    'titlepic'  => '',
		    'title'     => '',
		    'ttid'      => 0,
		    'newspath'  => '',
		    'filename'  => '',
		    'ispic'     => 0,
		    'groupid'   => 0,
		    'userfen'   => 0,
		    'titlefont' => '',
		    'stb'       => 1, //副表位置 默认为1
		    'fstb'      => 1,
		    'restb'     => 1,
		    'keyboard'  => '',

		    //自字义字段
		    'diggtop'   => 0
		],
		//副表
		'sec'   => [

		    //系统字段
		    'id'        => null,
		    'classid'   => 0,
		    'keyid'     => '',
		    'dokey'     => 0,
		    'newstempid'=> 0,
		    'closepl'   => 0,
		    'haveaddfen'=> 0,
		    'infotags'  => '',

		    //自定义字段
		    'writer'    => '',
		    'befrom'    => '',
		    'newstext'  => ''
		]
	];

	//副表的分表起始位
	private static $stb = 1; //默认副表起点
}
